<template>
  <div id="app">
    <ul>
      <li v-for="(item,index) in arr" :key=index>
        <span>{{item}}</span>
        <button @click="deleted" >删除</button>
      </li>
    </ul>
    <button @click="add">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [1, 5, 3],
    };
  },
  methods:{
    add(){
      this.arr.push(
           parseInt(Math.random()*100)
      )
    },
    deleted(){
        const id = this.arr.findIndex((index)=>index===this.index)
         this.arr.splice(id,1)
    }
  }
}
</script>